import socket

qq = socket.socket()

qq.bind(('127.0.0.1',8848))

qq.listen(3)

while 1:
    conn,addr = qq.accept()

    while 1:
        try:
            from_client = conn.recv(1024)
            if from_client == b'Q':
                break
            print(from_client.decode('utf-8'))

            data = input('>>>(输入1为勿扰模式)').strip()
            if data == '1':
                while 1:
                    conn.send('您好，我现在有事不在，请稍后联系'.encode('utf-8'))
                    print(conn.recv(1024).decode('utf-8'))

            conn.send(data.encode('utf-8'))
        except Exception:
            break

    conn.close()

qq.close()